#include <stdio.h>

struct Student
{
    int num;
    char name[20];
    int age;
};

int main(int argc, char **argv)
{
    struct Student stus[3] = {{1,"zhangsan",12},{2,"lisi", 13},{3,"wangwu",14}};
    FILE *fp = fopen(argv[1], "wb+");
    for(int i = 0; i < 3; i++)
    {
        fwrite(&stus[i], 1, sizeof(struct Student), fp);
        fflush(fp);
    }

    struct Student temp;
    rewind(fp);
    fseek(fp, sizeof(struct Student), SEEK_CUR);
    fread(&temp, 1, sizeof(struct Student), fp);
    printf("num = %d name = %s age = %d\n", temp.num, temp.name, temp.age);

    fclose(fp);
    
    return 0;
}